<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>
<html>
 <head>
    <title>菜单管理</title>
    <!-- import css and js -->
	<%@ include file="/common/meta.jsp" %>
	<script src="${ctx}/js/ligerUI/js/plugins/ligerLayout.js" type="text/javascript"></script>
	<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript">
		var basic_Url="${ctx}/security/menu";
		var show_Width=320;
		var show_Hight=150;
		var actionNodeID=null;
		function createSearch(){
			init(1,4,'100,100,100,100','20%');

			//第一行的数据
			addCommon(0,0,"lable","名称：");
			addCommon(0,1,"txtlike","name");
		}
		function searchAP(){			
			multipleSearch("#table1",true,"",basic_Url+"/list.do");
			
		}
		function gettreeData() 
		 {    
			multipleSearch("#table1",true,"",basic_Url+"/list.do?ID="+actionNodeID);
			var manager = null;
			manager = $("#tree1").ligerGetTreeManager(); 
			manager.clear();
	        manager.loadData(null, basic_Url+'/tree.do');
	        manager.collapseAll();
		 }
		$(function(){
			var grid = $("#table1").ligerGrid({
	            columns: [
	                      { display: '菜单名称', name: 'name', width: 200 },
	                      { display: '菜单路径', name: 'url', width: 200 },
	                      { display: '状态', name: 'removed', width: 145,
	                    	  render: function (item){
	                    		  var removed=item.removed;
	                    		  if(removed=="0"){
	                    			  return "正常";
	                    		  }
	                    		  if(removed=="1"){
	                    			  return "锁定";
	                    		  }
	                    	  }}
	                          ],  usePager: true,pageSize:30,
	                        //  url : basic_Url+"/list.do",
	                          width: 830, height:"98%", checkbox: true,      
	                          onDblClickRow : function (data, rowindex, rowobj){
	                        	  edit(data);
	                           },
	                          toolbar: { items: [
												  { text: '增加', click: additem, img: '../../js/ligerUI/skins/icons/add.gif' },
												  { line: true },
	                                              { text: '修改', click: edititem, img: '../../js/ligerUI/skins/icons/edit.gif' },
	                                              { line: true },
	                                              { text: '锁定', click: deltype, img: '../../js/ligerUI/skins/icons/delete.gif' }
	                                              ]
	                                              }
	                      });
	    	$("#pageloading").hide();
	    	
	    	
	    	$("#layout1").ligerLayout({ leftWidth: 200,height: '100%',heightDiff:-24,space:4});
	    	
	    	$("#tree1").ligerTree({  
	    		 url: basic_Url+'/tree.do',
	    		 nodeWidth: 115,
	    		 checkbox: false,
	             slide: false,
	             onClick:function(node){
	            	 actionNodeID = node.data.id;
	            	 multipleSearch("#table1",true,"",basic_Url+"/list.do?ID="+node.data.id);
	             }
	         });
	    	
	    	//添加菜单
	      	 function additem(){
	   			if(actionNodeID==null){
	   				$.dialog.alert("请先选择左侧父菜单");
	   				return false;
	   			}
	      		var url = "security/menu/operation/add/"+actionNodeID+".do";
	      		ShowIframeDialog("operate","添加菜单",url,320,300);
	      	 }
	      	 
	      	//修改菜单
	      	 function edititem(data){
	      		var manager = $("#table1").ligerGetGridManager(); 
  				var rows=manager.getSelectedRow(); 
  				if(rows==null){
  					$.dialog.alert("请先选择行记录");
  			   	 	return false;
  				}
	      			var url = "security/menu/operation/edit/"+rows.id+".do";
	      			ShowIframeDialog("operate","修改菜单",url,320,300);
	      	 }
	      	 
	      	 function edit(data){
		      		var url = "security/menu/operation/edit/"+data.id+".do";
		      		ShowIframeDialog("operate","修改菜单",url,320,300);
		     }
	      	 
	      	 //锁定菜单
	      	 function deltype(){
	      			var manager = $("#table1").ligerGetGridManager(); 
	      				var rows=manager.getSelectedRow(); 
	      				if(rows==null){
	      					$.dialog.alert("请先选择行记录");
	      			   	 	return false;
	      				}
	      				$.ajax({
	      				      url: basic_Url+"/detele.do",
	      				      global: false,
	      				      type: "POST",
	      				      dataType: "json",
	      				      data: ({
	      				    	  rows : rows.id
	      				      }),		     
	      				      success: function(msg){
	      				    	  if(msg.msg=="SUCCESS"){
	      				    		  $.dialog.alert("锁定成功");
	      				    	  }
	      				    	  if(msg.msg=="ERROR"){
	      				    		  $.dialog.alert("锁定失败");
	      				    	  }
	      				    	multipleSearch("#table1",true,"",basic_Url+"/list.do");
	      				   }
	      				});
	      	}
		});
	
	</script>
	
  </head>

 <body style="padding:10px" onLoad="createSearch()">  
       <div id="pageHeader" class="pageHeader">
               <div class="searchBar" id="multipleSearchDialog">
	                <table class="table" width="100%" id="searchHeader" >  
                        <tbody id="newbody">
                        </tbody>
 	                </table>
                    <div class="subBar">
			             <ul>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li>
				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
			             </ul>
	                </div>
               </div>
          </div>
      <div id="layout1">
            <div position="left" title="菜单管理">
            <div style="width:100%; height:380px; float:left;overflow:auto;  ">
   				 <ul id="tree1"></ul>
    		</div> 
            </div>
            <div position="center" title="菜单列表" id="table1">
            
            </div>  
        </div> 
    </body>
</html>